package org.mozhu.mboot.admin.maintain.notification.service;

import org.mozhu.mboot.admin.maintain.notification.entity.NotificationTemplate;
import org.mozhu.mboot.admin.maintain.notification.exception.TemplateNotFoundException;
import org.mozhu.mboot.admin.maintain.notification.repository.NotificationTemplateRepository;
import org.mozhu.mboot.core.data.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 通知模板 - 业务层实现类
 * 
 * @author ZhangPei
 */
@Transactional
@Service
public class NotificationTemplateServiceImpl extends BaseService<NotificationTemplate, Long> implements NotificationTemplateService {

	public NotificationTemplateRepository getBaseRepository() {
		return (NotificationTemplateRepository) baseRepository;
	}

	@Override
	public NotificationTemplate findByCode(String code) {
		NotificationTemplate notificationTemplate = getBaseRepository().findByCode(code);
		if (notificationTemplate == null) {
			throw new TemplateNotFoundException(code);
		}
		return notificationTemplate;
	}

}
